package com.affablebeans.model.program;

import java.sql.SQLException;
import java.util.List;

import com.affablebeans.model.dal.CategoryDAL;
import com.affablebeans.model.dal.CustomerDAL;
import com.affablebeans.model.dal.OrderDAL;
import com.affablebeans.model.dal.ProductDAL;
import com.affablebeans.model.entity.Category;
import com.affablebeans.model.entity.Customer;
import com.affablebeans.model.entity.Order;
import com.affablebeans.model.entity.Product;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

/**
 *
 * @author Bora SAYINER
 * @since Jan 26, 2015 3:54:38 PM
 * @version 1.0
 */
public class Driver {

	private static final MysqlDataSource dataSource = new MysqlDataSource();

	static {
		dataSource.setURL("jdbc:mysql://localhost:3306/affablebean");
		dataSource.setUser("root");
		dataSource.setPassword("Passw0rd");
	}

	public static void main(String[] args) throws SQLException {
		ProductDAL productDAL = new ProductDAL(dataSource);
//		List<Product> products = productDAL.getAll();
//		for (Product product : products) {
//			System.out.println(product);
//		}
		
//		List<Product> products = productDAL.findByCategory(1);
//		for (Product product : products) {
//			System.out.println(product);
//		}
		
//		CustomerDAL customerDAL = new CustomerDAL(dataSource);
//		List<Customer> customers = customerDAL.getAll();
//		for (Customer customer : customers) {
//			System.out.println(customer);
//		}
		
		OrderDAL orderDAL = new OrderDAL(dataSource);
		List<Order> orders = orderDAL.getAll();
		for (Order order : orders) {
			System.out.println(order);
		}
	}
}
